package com.liuxing.javaSpringBoot.modules.common.dao;

import com.liuxing.javaSpringBoot.modules.common.entity.ExceptionLog;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * @File ExceptionLogDao.java
 * @Auth liuxing
 * @Date 2021/8/25 09:06
 * @Email liuxing997@foxmail.com
 */
@Mapper
@Repository
public interface ExceptionLogDao {

    //查询异常日志
    @Select("select * from common_exception_log " +
            "where path = #{path} and  method_name = #{methodName} and exception_type = #{exceptionType} ")
    List<ExceptionLog> getExceptionLogsByParam(
            @Param("path") String path,
            @Param("methodName") String methodName,
            @Param("exceptionType") String exceptionType
    );

    //插入异常日志
    @Insert("insert into common_exception_log (ip,path,class_name,method_name,exception_type,exception_message,create_date)" +
            "values(#{ip},#{path},#{className},#{methodName},#{exceptionType},#{exceptionMessage},#{createDate})")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void insertExceptionLog(ExceptionLog exceptionLog);
}
